package com.zc.im.mapper.customer;

import com.zc.im.model.customer.ZcCustomerService;
import com.zc.im.model.customer.ZcCustomerServiceExample;
import com.zc.im.model.customer.ZcCustomerServiceKey;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface ZcCustomerServiceMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    int countByExample(ZcCustomerServiceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    int deleteByExample(ZcCustomerServiceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    @Delete({
        "delete from zc_customer_service",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(ZcCustomerServiceKey key);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    @Insert({
        "insert into zc_customer_service (id, user_id, ",
        "customer_service_type, customer_service_name, ",
        "service_user_num, desc, ",
        "addr, created_time, ",
        "updated_time, company_id, ",
        "status)",
        "values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, ",
        "#{customerServiceType,jdbcType=VARCHAR}, #{customerServiceName,jdbcType=VARCHAR}, ",
        "#{serviceUserNum,jdbcType=INTEGER}, #{desc,jdbcType=VARCHAR}, ",
        "#{addr,jdbcType=VARCHAR}, #{createdTime,jdbcType=TIMESTAMP}, ",
        "#{updatedTime,jdbcType=TIMESTAMP}, #{companyId,jdbcType=INTEGER}, ",
        "#{status,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=true, resultType=Integer.class)
    int insert(ZcCustomerService record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    int insertSelective(ZcCustomerService record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    List<ZcCustomerService> selectByExample(ZcCustomerServiceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    @Select({
        "select",
        "id, user_id, customer_service_type, customer_service_name, service_user_num, ",
        "desc, addr, created_time, updated_time, company_id, status",
        "from zc_customer_service",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    ZcCustomerService selectByPrimaryKey(ZcCustomerServiceKey key);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    int updateByExampleSelective(@Param("record") ZcCustomerService record, @Param("example") ZcCustomerServiceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    int updateByExample(@Param("record") ZcCustomerService record, @Param("example") ZcCustomerServiceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(ZcCustomerService record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table zc_customer_service
     *
     * @mbggenerated
     */
    @Update({
        "update zc_customer_service",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "customer_service_type = #{customerServiceType,jdbcType=VARCHAR},",
          "customer_service_name = #{customerServiceName,jdbcType=VARCHAR},",
          "service_user_num = #{serviceUserNum,jdbcType=INTEGER},",
          "desc = #{desc,jdbcType=VARCHAR},",
          "addr = #{addr,jdbcType=VARCHAR},",
          "created_time = #{createdTime,jdbcType=TIMESTAMP},",
          "updated_time = #{updatedTime,jdbcType=TIMESTAMP},",
          "company_id = #{companyId,jdbcType=INTEGER},",
          "status = #{status,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ZcCustomerService record);


    @Select({
            "select",
            "id, user_id, customer_service_type, customer_service_name, service_user_num, ",
            "`desc`, addr, created_time, updated_time, company_id, status",
            "from zc_customer_service",
            "where customer_service_type = #{customerServiceType,jdbcType=VARCHAR}",
            "order by service_user_num asc limit 1"
    })
    @ResultMap("BaseResultMap")
    ZcCustomerService findCustomerServiceForMinNum(ZcCustomerService record);
}